/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.chart.AStoreReport;
import com.thor.palmmall.spi.chart.StoreReport;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class AStoreReportConverter implements Converter<StoreReport, AStoreReport> {

  public static AStoreReportConverter getInstance() {
    if (instance == null)
      instance = new AStoreReportConverter();
    return instance;
  }

  private static AStoreReportConverter instance;

  private AStoreReportConverter() {
  }

  @Override
  public AStoreReport convert(StoreReport source) {
    if (source == null) {
      return null;
    }
    AStoreReport target = new AStoreReport();
    target.setCode(source.getCode());
    target.setName(source.getName());
    target.setOpenDate(source.getOpenDate());
    target.setPassengers(source.getPassengers());
    target
        .setPictures(ConverterUtil.convert(source.getPictures(), APictureConverter.getInstance()));
    target.setSalesTotal(source.getSalesTotal());
    target.setUuid(source.getUuid());
    return target;
  }

}
